from fastapi import UploadFile
from service.file_service import FileService


def file_embedding(file:UploadFile,
                   file_service:FileService,
                   file_id:str= None,
                   course_id:str=None):
     data = file_service.load_file(file)
     chunks=file_service.split_file(data)
     for chunk in chunks:
         embedding=file_service.embedding(chunk)
         do = {"embedding": embedding,"content":chunk.page_content,"file_id":file_id,"course_id":course_id,"file_name":file.filename}
         file_service.insert_to_milvus(do)
